package org.headquarter.business;

import org.headquarter.object.Node;
import org.headquarter.object.UnicId;
import org.headquarter.persistance.LoadError;
import org.headquarter.persistance.NodePersister;
import org.headquarter.persistance.SaveError;
import org.headquarter.search.IndexError;
import org.headquarter.search.NodeSearcher;

public class NodeManager {

    NodeSearcher nodeSearcher;
    public NodeSearcher getNodeSearcher() {
        return nodeSearcher;
    }

    NodePersister nodePersister;
    public NodeManager() {

    }

    public void setNodePersister(NodePersister nodePersister){
	this.nodePersister = nodePersister;
    }

    public void setNodeSearcher(NodeSearcher nodeSearcher){
	this.nodeSearcher =nodeSearcher;
    }

    public void saveNode(Node node) throws SaveError, IndexError{
	nodePersister.save(node);
	nodeSearcher.index(node);
    }


    public Node getNode(UnicId id) throws LoadError{
	return nodePersister.load(id);
    }

    public void removeNode(UnicId id){
	nodePersister.deleteNode(id);
    }

    public void shutdown() throws IndexError {
	nodeSearcher.shutdown();
	
    }



}
